#!/bin/bash

TMP_SOLUTION=/tmp/tmp_solution_$RANDOM

PREFIX=$1
SOLUTIONS_FILE=../${PREFIX}.solutions
INPUT_FILE=${PREFIX}.cnf.results

CHECK_SOLUTION=../check_solution.sh

UNMATCHED=0

while read line
do

	if [[ $line =~ (("-")?[1-9][0-9]*" ")+"0" ]]
	then
		echo $line > $TMP_SOLUTION

		$CHECK_SOLUTION $TMP_SOLUTION $SOLUTIONS_FILE

		if [[ "$?" == "0" ]]
		then
			echo "Solutions matched"
		else
			echo "A solution did not match!"
			let UNMATCHED++
		fi

	fi


done < $INPUT_FILE

if [[ "$UNMATCHED" == "0" ]]
then
	echo "All solutions matched!"
else
	echo "$UNMATCHED solutions did not match!"
fi
